AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
include('shared.lua')

function ENT:Use(activator, caller)
	if !caller:GetNWBool("Helmetd") then
		self.BaseClass.Use(self, activator, caller)
	end
end

function ENT:GiveItemEffects(ply)
	ply:SetNWBool("Helmetd", true)
end

local function Helmet(ply, hitgroup, dmginfo)
	if hitgroup == HITGROUP_HEAD && ply:GetNWBool("Helmetd") then
		dmginfo:ScaleDamage(0.3)
		local effectdata = EffectData()
		effectdata:SetOrigin(ply:GetPos() + Vector(0, 0, 60))
		effectdata:SetMagnitude(1)
		effectdata:SetScale(1)
		effectdata:SetRadius(2)
		util.Effect("Sparks", effectdata, true, true)
	else
		dmginfo:ScaleDamage(1.3)
	end	
end
hook.Add("ScalePlayerDamage", "Helmet", Helmet)

local function UnHelmet(ply)
	ply:SetNWBool("Helmetd", false)
end
hook.Add("PlayerDeath", "Helmet", UnHelmet)